package com.mq.receiver;

import com.mq.bean.Order;
import com.mq.servcie.MyChannel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;

/**
 * Created by Administrator on 2017/8/29 0029.
 * 接收消息类
 */
@EnableBinding(MyChannel.class)
public class Receiver {
    private final static Logger logger = LoggerFactory.getLogger(Receiver.class);
    // 监听 binding 为 OrderIntf.INPUT_ORDER 的消息
    @StreamListener(MyChannel.INPUT_ORDER)
    public void inputOrder(Order order) {
        /*System.out.println("=====订单监听收到=====");
        System.out.println("订单编号：" + order.getOrderNum());
        System.out.println("订单类型：" + order.getType());
        System.out.println("订单数量：" + order.getNum());
        System.out.println("下单时间："+order.getCreateAt());
        System.out.println("=====订单处理完成=====");*/
        logger.info("\n=====订单监听收到=====\n订单编号：{}\n订单类型：{}\n订单数量：{}\n下单时间：{}\n=====订单处理完成====="
        ,order.getOrderNum(),order.getType(),order.getNum(),order.getCreateAt()
        );
    }
}
